import { Injectable, NestMiddleware, UnauthorizedException } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';

@Injectable()
export class AuthLoginMiddleware implements NestMiddleware {
  use(req: Request, res: Response, next: NextFunction) {
    const session = req.session as any;
    if (!session || !session.userId) {
      throw new UnauthorizedException('用户未登录');
    }
    next();
  }
} 